<template>
    <view class="layout">
        <uni-header :leftIcon="true" :title="title"></uni-header>
        <view class="content">
            <view class="profile-text" v-if="activity.img_urls === ''">暂时没有教学资料</view>
            <view class="profile-img" v-else><img :src="imgUrl+activity.img_urls"></view>

        </view>
    </view>
</template>

<script>
    import {getActivity, getEmulateActivity } from "@/api/home"
    import config from '@/config'
    export default {
        data() {
            return {
                imgUrl:config.imgUrl,
                type: "",
                title: "教学资料",
                activeId: "",
                deviceId: this.$store.state.user.deviceId,
                activity: {},
            }
        },
        onLoad(option) {
            this.activeId = option.activeId;
            this.type = option.type;
            if (this.type == "class") {
                this.getClassActive();
            } else if (this.type == "emulate") {
                this.getEmulateActive()
            }
        },
        methods: {
            //获取听评课下教学资料
            getClassActive() {
                getActivity({
                    id: this.activeId,
                    deviceId: this.deviceId
                }).then(res => {
                    console.log(res)
                    this.activity = res.activity;
                })
            },
            //获取观摩课下教学资料
            getEmulateActive() {
                getEmulateActivity({
                    id: this.activeId,
                    deviceId: this.deviceId
                }).then(res => {
                    console.log(res)
                    this.activity = res.activity;
                })
            },


        }
    }
</script>

<style lang="scss">
    .layout {
        .profile-img{
            width: 100%;
        }
        .profile-text{
            font-size: 3rem;
            color:#999;
            text-align: center;
            margin: 30px 0;
        }
    }
</style>
